package com.zg.system.extra;

import com.zg.common.core.R;
import com.zg.common.core.util.KaptchaUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.script.ScriptException;

/**
 * @author Zxb
 */
@RestController
public class CaptchaController {
    @GetMapping("/un/captcha/create")
    public R<?> captcha() throws ScriptException{
        String[] result = KaptchaUtil.generate();
        return R.success(result);
    }

    @GetMapping("/un/captcha/validate")
    public R<?> validate(String sign, String captcha) {
        return R.success(KaptchaUtil.validate(sign, captcha));
    }
}
